home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / comm / irc / epic4-mos.lha / share / epic / script / debug.irc < prev    next >
Text File  |  2002-09-18  |  2KB  |  95 lines

  1. # 23 Feb 1999 - Dracus
  2.  
  3. alias debug_section {
  4.         @ logstate = log
  5.         if (log == [on]) {
  6.                 @ logfile_old = logfile
  7.                 ^set log off
  8.         }
  9.         ^set logfile epic.dbg
  10.         ^set log on
  11.         ^set debug 7
  12.         }
  13.  
  14. alias debug_endsection {
  15.         set debug 0
  16.         ^set log off
  17.         ^set logfile $logfile_old
  18.         ^set log $logstate
  19. }
  20.  
  21. #dracus'99
  22.  
  23. # Time the execution of a given command.
  24. #
  25. # Usage:
  26. #  call.time [command]
  27. #
  28. alias call.time {
  29.     @ :u1 = utime()
  30.     $*
  31.     @ :u2 = utime()
  32.     stack push set floating_point_math
  33.     ^set floating_point_math on
  34.     @ :time = (shift(u2) - shift(u1)) + ((shift(u2) - shift(u1)) / 1000000)
  35.     @ :time = trunc(6 $time)
  36.     stack pop set floating_point_math
  37.     if (functioncall()) {
  38.         return $time
  39.     } else {
  40.         echo $tdiff($time): $*
  41.     }
  42. }
  43.  
  44. # Trace a given command.
  45. #
  46. # This works by setting the value of debug to debug_level.
  47. # See "/help 4 set debug" for information about this setting.
  48. #
  49. # Usage:
  50. #  call.trace [debug_level [command]]
  51. #
  52. alias call.trace {
  53.     @ :hooks = [set debug set output_rewrite on window on yell]
  54.     fe ($hooks) foo bar {
  55.         stack push $foo $bar
  56.         $foo -$bar
  57.     }
  58.     ^set debug $0
  59.     $1-
  60.     fe ($hooks) foo bar {
  61.         stack pop $foo $bar
  62.     }
  63. }
  64.  
  65. # Trace a given command.
  66. #
  67. # Debug_levels is a comma seperated list of values to apply to /xdebug.
  68. # See "/help 4 xdebug" for information about debug_levels, but do not use
  69. # +/- notation, and seperate the values with commas instead of spaces.
  70. #
  71. # Note:  Since it is not possible to read the current xdebug setting, all
  72. #        listed levels will be unset when this alias returns.
  73. #
  74. # Usage:
  75. #  call.xtrace [debug_levels [command]]
  76. #
  77. alias call.xtrace {
  78.     @ :hooks = [set output_rewrite on window on yell]
  79.     @ :oxd = xdebug()
  80.     @ :debugon = :debugoff = split(, $0)
  81.     repeat $#debugoff {
  82.         @unshift(debugon +$pop(debugon))
  83.         @unshift(debugoff -$pop(debugoff))
  84.     }
  85.     fe ($hooks) foo bar {
  86.         stack push $foo $bar
  87.     }
  88.     xdebug $debugon
  89.     $1-
  90.     xdebug $debugoff $oxd
  91.     fe ($hooks) foo bar {
  92.         stack pop $foo $bar
  93.     }
  94. }
  95.